﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace BooruViewer
{
    class JsonGetter
    {
        public static string GetJson (string url)
        {
            var json = "";

            using (var webClient = new WebClient())
            {
                webClient.Headers.Add("Accept", "application/json"); 
                webClient.Headers.Add("User-Agent", "BooruViewer/1.0.0 (angius@pm.me)"); 
                try
                {
                    json = webClient.DownloadString(url);
                }
                catch (WebException e)
                {
                    json = "ERROR FETCHING JSON: " + e;
                }
            }

            return json;
        }
    }
}
